"垃圾分类"
from optparse import Option
from turtle import back, pen


waste_dict = {
    "可回收":["玻璃","金属","塑料瓶"],
    "不可回收":["餐巾纸","塑料袋","纸尿裤"],
    "有害垃圾":["电池","油漆","化工品"],
    "湿垃圾":["剩饭剩菜","瓜皮","过期食品"],
}
while True:
    search_waste = input("输入查询的垃圾：")
    find = False
    if search_waste == "q":
        break
    for classify , waste in waste_dict.items():
        if search_waste in waste :
            find = True
            print(f"{search_waste}类别是{classify}")
            print("-"*30)
    if find == False :
        print("NO,库中没有,请自行判断")
        print("-"*30)
        for classify,waste in waste_dict.items():
            print(f"{classify}包括：",end="  ")
            for item in waste :
                if waste.index(item) == len(waste) -1:
                    print(item)
                else:
                    print(item,end=",")
        print("-"*30)
        while True:
            option = input("是否添加到类？(yes/no)")
            if option == "yes":
                classify = input("添加到那个类")
                try:
                    waste_dict[classify].append(search_waste)
                except KeyError:
                    print("输入有误，没有这个类")
                break
            elif option == "no":
                print("可以继续查询")
                break
            else:
                print("输入有误，请重新输入")    